import { RouteRecordRaw } from 'vue-router';

// 扩展 RouteMeta 接口
declare module 'vue-router' {
	interface RouteMeta {
		title?: string;
		isLink?: string;
		isHide?: boolean;
		isKeepAlive?: boolean;
		isAffix?: boolean;
		isIframe?: boolean;
		roles?: string[];
		icon?: string;
	}
}

/**
 * 定义动态路由
 * 前端添加路由，请在顶级节点的 `children 数组` 里添加
 * @description 未开启 isRequestRoutes 为 true 时使用（前端控制路由），开启时第一个顶级 children 的路由将被替换成接口请求回来的路由数据
 * @description 各字段请查看 `/@/views/system/menu/component/addMenu.vue 下的 ruleForm`
 * @returns 返回路由菜单数据
 */
export const dynamicRoutes: Array<RouteRecordRaw> = [
	{
		path: '/',
		name: '/',
		redirect: '/staff',
		component: () => import('/@/layout/index.vue'),
		meta: {
			isKeepAlive: true,
		},
		children: [
			{
				path: '/staff',
				name: 'staff',
				component: () => import('/@/views/staff/index.vue'),
				meta: {
					title: '员工管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					meta: { requiresAuth: true },
					roles: ['admin', 'common'],
					icon: 'iconfont icon-shouye',
				},
			},
			{
				path: '/permissions',
				name: 'permissions',
				meta: {
					title: '权限管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: false,
					isIframe: false,
					roles: ['admin'],
					icon: 'iconfont icon-xitongshezhi',
				},
				children: [
					{
						path: 'admin',
						name: 'admin',
						component: () => import('/@/views/permissions/admin.vue'),
						meta: {
							title: '账户管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'iconfont icon-caidan',
						},
					},
					{
						path: 'menus',
						name: 'menus',
						component: () => import('/@/views/permissions/menus.vue'),
						meta: {
							title: '菜单管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-ColdDrink',
						},
					},
					{
						path: 'role',
						name: 'role',
						component: () => import('/@/views/permissions/role.vue'),
						meta: {
							title: '角色管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'iconfont icon-icon-',
						},
					},
					{
						path: 'cardType',
						name: 'cardType',
						component: () => import('/@/views/permissions/cardType.vue'),
						meta: {
							title: '证书分类',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-OfficeBuilding',
						},
					},
					{
						path: 'sort',
						name: 'sort',
						component: () => import('/@/views/permissions/sort.vue'),
						meta: {
							title: '薪资审核',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					},
				],
			},
			{
				path: '/companys',
				name: 'companys',
				meta: {
					title: '组织管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: false,
					isIframe: false,
					roles: ['admin'],
					icon: 'iconfont icon-quanxian',
				},
				children: [
					{
						path: 'company',
						name: 'company',
						component: () => import('/@/views/companys/company.vue'),
						meta: {
							title: '组织管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					}
				],
			},
			{
				path: '/basePay',
				name: 'basePay',
				meta: {
					title: '薪资管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: false,
					isIframe: false,
					roles: ['admin'],
					icon: 'iconfont icon-quanxian',
				},
				children: [
					{
						path: 'gride',
						name: 'gride',
						component: () => import('/@/views/basePay/gride.vue'),
						meta: {
							title: '档级管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					},
					{
						path: '/salary',
						name: 'salary',
						component: () => import('/@/views/basePay/salary.vue'),
						meta: {
							title: '薪资管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					},
					{
						path: '/wagesand',
						name: 'wagesand',
						component: () => import('/@/views/basePay/wagesand.vue'),
						meta: {
							title: '社保管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					},
					{
						path: '/companyAdmin',
						name: 'companyAdmin',
						component: () => import('/@/views/basePay/companyAdmin.vue'),
						meta: {
							title: '凭证管理',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					},
					{
						path: '/attendance',
						name: 'attendance',
						component: () => import('/@/views/basePay/attendance.vue'),
						meta: {
							title: '员工考勤',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					}
				],
			},
			{
				path: '/item',
				name: 'item',
				component: () => import('/@/views/item/index.vue'),
				meta: {
					title: '项目管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: false,
					isIframe: false,
					roles: ['admin'],
					icon: 'iconfont icon-shouye',
				},
			},
			{
				path: '/recruiting',
				name: 'recruiting',
				component: () => import('/@/views/recruiting/recruiting.vue'),
				meta: {
					title: '招聘管理',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: false,
					isIframe: false,
					roles: ['admin'],
					icon: 'iconfont icon-shouye',
				},
			},
			{
				path: '/agreement',
				name: 'agreement',
				meta: {
					title: '合同协议',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: false,
					isIframe: false,
					roles: ['admin'],
					icon: 'iconfont icon-quanxian',
				},
				children: [
					{
						path: 'signature',
						name: 'signature',
						component: () => import('/@/views/agreement/signature.vue'),
						meta: {
							title: '签章配置',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					},
					{
						path: '/contract',
						name: 'contract',
						component: () => import('/@/views/agreement/contract.vue'),
						meta: {
							title: '合同分类',
							isLink: '',
							isHide: false,
							isKeepAlive: true,
							isAffix: false,
							isIframe: false,
							roles: ['admin'],
							icon: 'ele-SetUp',
						},
					}
				],
			},
			{
				path: '/feedback',
				name: 'feedback',
				component: () => import('/@/views/feedback/feedback.vue'),
				meta: {
					title: '意见反馈',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					roles: ['admin'],
					icon: 'iconfont icon-shouye',
				},
			}
		],
	},
];

/**
 * 定义404、401界面
 * @link 参考：https://next.router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
 */
export const notFoundAndNoPower = [
	{
		path: '/:path(.*)*',
		name: 'notFound',
		component: () => import('/@/views/error/404.vue'),
		meta: {
			title: 'message.staticRoutes.notFound',
			isHide: true,
		},
	}
];

/**
 * 定义静态路由（默认路由）
 * 此路由不要动，前端添加路由的话，请在 `dynamicRoutes 数组` 中添加
 * @description 前端控制直接改 dynamicRoutes 中的路由，后端控制不需要修改，请求接口路由数据时，会覆盖 dynamicRoutes 第一个顶级 children 的内容（全屏，不包含 layout 中的路由出口）
 * @returns 返回路由菜单数据
 */
export const staticRoutes: Array<RouteRecordRaw> = [
	{
		path: '/login',
		name: 'login',
		component: () => import('/@/views/login/index.vue'),
		meta: {
			title: '登录',
		},
	}
];
